#encoding=utf8
'''
Created on 2012-10-18

@author: Administrator
'''
from DbOperator import DbOperator
from Feedback import Feedback
from pub import Func
from pub.Config import Config
class FeedbackModel(DbOperator):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        DbOperator.__init__(self)
    def addNew(self,oFeedback):
        """
        增加一条新的反馈信息
        @param oFeedback:Feedback
        @return: tuple 
        """
        if(oFeedback):
            values = (
                      Feedback.FEEDCONTENT,oFeedback.get_content(),
                      Feedback.CREATED,oFeedback.get_created(),
                      Feedback.FEEDUSERID,oFeedback.get_user_id(),
                      Feedback.FEEDIP,oFeedback.get_feed_ip(),
                      )
            aParam={Config.S_TABLE:Feedback.TABLE_NAME,
                    Config.S_SEARCHFIELDS:"`%s`='%s',`%s`='%s',`%s`='%s',`%s`='%s' "%values,
            }
            return (self.doInsert(aParam),Config.I_FEEDBACK_ADD_OK)
    def delFeed(self,iFeedId):
        """
        根据Id删除反馈信息
        @param iFeedId:int    要删除的信息Id
        """
        aParam = {
           Config.S_TABLE:Feedback.TABLE_NAME,
           Config.S_SEARCHCONDITION:" `%s`=%s  " %  (Feedback.PRIMARY_KEY,iFeedId),
         }
        return self.doDelete(aParam)
if __name__=="__main__":
    oFeed = Feedback()
    oFeed.set_user_id(10)
    oFeed.set_feed_ip("127.0.0.1")
    oFeed.set_content("应用什么时候上线啊?")
    oFeed.set_created(Func.getNow())
    mFeed = FeedbackModel()
    mFeed.addNew(oFeed)
    mFeed.delFeed(1)